﻿namespace DadayunApi.Model
{
    /// <summary>
    /// 流程节点类
    /// </summary>
    public class WFNode
    {
        public string Id { get; set; }
        public string Name { get; set; }
        /// <summary>
        /// 本地化节点名称
        /// </summary>
        public string InternationalName { get; set; }
        /// <summary>
        /// 所属工作流模板ID
        /// </summary>
        public string WFTplId { get; set; }
        public ENodeType NodeType { get; set; }
        /// <summary>
        /// 节点状态，运行时才有
        /// </summary>
        public string status { get; set; }
        /// <summary>
        /// 是否结束节点
        /// </summary>
        public bool IsEndNode { get; set; }
        /// <summary>
        /// 节点任务类型
        /// </summary>
        public EActionType ActionType { get; set; }
        /// <summary>
        /// 节点通过按钮文字
        /// </summary>
        public string ApproveText { get; set; }
        /// <summary>
        /// 节点驳回按钮文字
        /// </summary>
        public string RejectText { get; set; }
        /// <summary>
        /// 任务转入类型
        /// </summary>
        public EInType InType { get; set; }
        /// <summary>
        /// 任务转入类型为3时的指定数量
        /// </summary>
        public int InThreshold { get; set; }
        /// <summary>
        /// 任务转出类型
        /// </summary>
        public EOutType OutType { get; set; }
        /// <summary>
        /// 多执行者的任务转出类型
        /// </summary>
        public EMultiActorOutType MultiActorOutType { get; set; }
        public int MultiActorOutThreshold { get; set; }
        /// <summary>
        /// 允许分拆审批
        /// </summary>
        public bool CanSplitFormData { get; set; }
        /// <summary>
        /// 分拆审批设置
        /// </summary>
        public SplitFormDataConfig SplitFormDataConfig { get; set; }
        /// <summary>
        /// 流程节点执行者
        /// </summary>
        public WFNodeActor[] WFNodeActors { get; set; }
        /// <summary>
        /// 流程节点流转到下一节点的条件。一个节点可以流转到多个节点
        /// </summary>
        public WFTansactionCondition[] FTansactionConditions { get; set; }
    }

    public class WFTansactionCondition
    {
        /// <summary>
        /// 流转节点Id
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// 当前所在节点ID
        /// </summary>
        public string WFNodeId { get; set; }
        /// <summary>
        /// 流转到指定节点的条件
        /// </summary>
        public string Condition { get; set; }
        /// <summary>
        /// 流转到的目标节点Id
        /// </summary>
        public string TargetNodeId { get; set; }
        /// <summary>
        /// 目标节点名抽
        /// </summary>
        public string TargetNodeName { get; set; }
    }

    /// <summary>
    /// 流程节点执行者。一个节点可以设置多个执行者
    /// </summary>
    public class WFNodeActor
    {
        public string Id { get; set; }
        public string WFNodeId { get; set; }
        /// <summary>
        /// 执行者类型
        /// </summary>
        public EActorType ActorType { get; set; }
        /// <summary>
        /// 参与者ID
        /// </summary>
        public string CompositeId { get; set; }
        public string CompositeName { get; set; }
        /// <summary>
        /// 动态执行者配置
        /// </summary>
        public string DynamicActorDatas { get; set; }
    }

    /// <summary>
    /// 分拆审批设置类
    /// </summary>
    public class SplitFormDataConfig
    {
        /// <summary>
        /// 表单模板ID
        /// </summary>
        public string FormTplId { get; set; }
        /// <summary>
        /// 表单拆分的依据字段
        /// </summary>
        public string[] FormItemListIds { get; set; }
    }

    public enum EMultiActorOutType
    {
        /// <summary>
        /// 任一执行者代表所有执行者执行完毕时转出（默认值）
        /// </summary>
        OneActorForAll=0,
        /// <summary>
        /// 任一执行者执行完毕时转出
        /// </summary>
        OneActor=1,
        /// <summary>
        /// 所有执行者执行完毕时转出
        /// </summary>
        AllActor=2,
        /// <summary>
        /// 不少于MultiActorOutThreshold数量的执行者执行完毕时转出
        /// </summary>
        NotLessThanMultiActorOutThreshold = 3
    }
    /// <summary>
    /// 任务转出类型
    /// </summary>
    public enum EOutType
    {
        /// <summary>
        /// 满足条件的所有分支
        /// </summary>
        AllBranches=1,
        /// <summary>
        /// 满足条件的第一分支
        /// </summary>
        FirstBranch=2
    }
    /// <summary>
    /// 任务转入类型
    /// </summary>
    public enum EInType
    {
        /// <summary>
        /// 所有分支到达时
        /// </summary>
        AllBranches=1,
        /// <summary>
        /// 任一分支到达时
        /// </summary>
        OneBranche=2,
        /// <summary>
        /// 不小于InThreshold数量的分支到达时
        /// </summary>
        NotLessThanBranches=3
    }
    /// <summary>
    /// 节点任务类型
    /// </summary>
    public enum EActionType
    {
        审核审批=1,
        知会=2,
        执行确认=3,
        开始节点=4,
        无效=5
    }
    /// <summary>
    /// 节点类型
    /// </summary>
    public enum ENodeType
    {
        常规节点=1,
        自动化节点=2,
        结束节点=3
    }
}